import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const modules = {}
const require_module = require.context('./modules', false, /.js$/)
require_module.keys().forEach(file_name => {
    modules[file_name.slice(2, -3)] = require_module(file_name).default
})

export default new Vuex.Store({
    modules: modules,
    // strict: process.env.NODE_ENV !== 'production', // 关闭严格模式
    strict: false,
    plugins: [createPersistedState({
            // storage: window.sessionStorage,//设置存储成sessionStorage存储
            reducer(val) {
                return {
                    user: val.user,
                }
            }
        }
    )],
})
